<template>
	<view>
		<view class="choujiang">
			<image class="prize" src="@/static/images/newhone/good.jpg"></image>
			<scroll-view scroll-y="true" class="scrollView">
				<view class="list" v-for="item in blindBoxList" :key="item.id" @click="openbox(item)">
					<view class="l">
						<image :src="item.cover_image"></image>
					</view>
					<view class="r">
						<view class="name">{{item.name}}</view>
						<view class="price">￥{{item.first_blood}}</view>
						<view class="prob">
							至尊0.004% 史诗0.600% 稀有6.00%
						</view>
						<view class="goods">
							<image v-for="good in allFilterGoodslist" :key="good.goods_id" :src="good.cover_image">
							</image>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<tabBar :currentPage="4" :messageNum="messageNum" />
	</view>
</template>

<script>
	import tabBar from '@/components/tabBar';
	export default {
		components: {
			tabBar

		},
		data() {
			return {
				messageNum: 0,
				blindBoxList: [],
				allFilterGoodslist: []
			}
		},
		onLoad() {
			this.getBlindboxlist()
			this.getGoodsList()
		},
		methods: {

			openbox(item) {
				if (!uni.getStorageSync('token')) {
					uni.showModal({
						title: '温馨提示',
						content: '登录后可继续操作，是否登录？',
						success: res => {
							if (res.confirm) {
								uni.navigateTo({
									url: '/pages/login/login'
								});
							}
						}
					});
				} else {
					uni.navigateTo({
						url: `/pages/index/extractionBlindbox?id=${item.id}`
					});
				}
			},
			getBlindboxlist() {
				this.$api
					.activityList({
						offset: 1,
						activity_category_id: 0
					})
					.then(res => {
						this.blindBoxList = res;
					});
			},
			//获取盲盒全部商品
			getGoodsList() {
				this.$api
					.indexMoregoods({
						activity_id: "56",
						type: 0
					})
					.then(res => {
						this.allFilterGoodslist = res.splice(0, 4)
					});
			},
		}
	}
</script>

<style scoped lang="scss">
	.choujiang {
		width: 100vw;
		height: 100vh;
		overflow-y: auto;
		background-image: url('@/static/images/newhone/bg12.png');
		background-repeat: no-repeat;
		background-size: cover;
		padding-bottom: 66px;
		padding-top: 450rpx;

		.prize {
			width: 200rpx;
			height: 200rpx;
			position: absolute;
			right: 130rpx;
			top: 100rpx;
			// animation: fudong 3s infinite linear;
		}

		@keyframes fudong {
			0% {
				top: 90rpx;
			}

			50% {
				top: 110rpx;
			}

			100% {
				top: 90rpx;
			}
		}

		.scrollView {
			height: calc(100vh - 450rpx - 66px);
			.list {
				width: 735rpx;
				height: 302rpx;
				background-image: url('@/static/images/newhone/bg11.png');
				background-repeat: no-repeat;
				background-size: cover;
				margin: auto;
				padding: 34rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.l {
					margin-right: 22rpx;

					image {
						width: 236rpx;
						height: 236rpx;
					}
				}

				.r {
					.name {
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #1E1E1E;
					}

					.price {
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #1E1E1E;
						margin: 15rpx 0 20rpx;
					}

					.prob {
						font-size: 22rpx;
						font-family: PingFang SC;
						color: #888888;
						display: flex;
						align-items: center;
						justify-content: space-between;
					}

					.goods {
						display: flex;
						align-items: center;
						justify-content: space-between;
						margin-top: 20rpx;

						image {
							width: 82rpx;
							height: 82rpx;
							margin-right: 22rpx;
						}
					}

				}
			}
		}
	}
</style>
